package com.wukong.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class AnnouncementService {

    @Autowired
    private AnnouncementMapper announcementMapper;

    public void createAnnouncement(Announcement announcement) {
        announcement.setCreatedAt(LocalDateTime.now());
        announcement.setUpdatedAt(LocalDateTime.now());
        announcementMapper.insertAnnouncement(announcement);
    }

    public Announcement getAnnouncement(Long id) {
        return announcementMapper.selectAnnouncementById(id);
    }

    public List<Announcement> getAllAnnouncements() {
        return announcementMapper.selectAllAnnouncements();
    }
}